package javaDemo;

import java.io.IOException;
import java.net.*;

public class UDPReceiveDemo {

    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(10086);

        byte[] bytes = new byte[1024];


        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);

        while (true) {

            datagramSocket.receive(dp);
            String str = new String(dp.getData(),0,dp.getLength());
            System.out.println("接受数据："+str);

               // datagramSocket.close();
            //}

        }

    }
}
